/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package skipass;

/**
 *
 * @author andrii
 */
public class NumberOfRidesPass extends DaysOfTheWeekAbstractPass {

    private int leftRides;
    private final NumberOfRides rides;

    NumberOfRidesPass(NumberOfRides rides, DaysOfTheWeek week) {
        super(week);
        this.rides = rides;
        leftRides = rides.getNumberOfRides();
        isValid = true;
    }

    private boolean isFreeRides() {
        return leftRides-- > 0;
    }

    @Override
    public boolean validate() {
        return isValid()
                && isCorrectDayOfTheWeek()
                && isFreeRides();
    }

}
